class sensor_pie_slices(object):
	"""This sensor takes in a partitions (angles relative to the heading) and returns a list of the activation levels of each bin.  The partitions should be entered in the range of -pi to pi and must be unique, this list will be sorted, and the 0th area will be bounded by the smallest and largest bounds, the next will be bounded by the two smallest bounds, and so on."""
	def __init__(self,agent_num,world_model,pie_slice_bounds,max_range=1e10000):
		pie_slice_bounds.sort()
		self.agent_num=agent_num
		pie_slice_bounds=pie_slice_bounds[-1:]+pie_slice_bounds # Copy the last element to the front of the list
		self.max_range=max_range
		self.world_model=world_model
		self.bin_bounds=[None]*(len(pie_slice_bounds)-1)
		for i in xrange(len(self.bin_bounds)):
			self.bin_bounds[i]=[pie_slice_bounds[i],pie_slice_bounds[i+1]]
	def sense(self):
		activation_bins=[0]*len(self.bin_bounds)
		rel_locations=filter(lambda x: x[1] <= self.max_range,self.world_model.rel_agent_locations(self.agent_num))
		for location in rel_locations:
			for bound in xrange(len(self.bin_bounds)):
				if (min(self.bin_bounds[bound])<=location[0]<max(self.bin_bounds[bound])) ^ (self.bin_bounds[bound][0] >self.bin_bounds[bound][1]):
					activation_bins[bound]+=1
					break
		return activation_bins
